<?php


    $dir = pathinfo($_SERVER['SCRIPT_FILENAME']); 

    if (ini_set("include_path",ini_get("include_path").((strtoupper(PHP_OS) == "LINUX") ? ":" : ";").$dir['dirname']) === false) {
            echo "ERROR: Definicion en el include_path";
            exit;
    }


    include('../adodb/adodb.inc.php');
    include_once('../adodb/adodb-pager.inc.php');
    include_once('../conf/dbconn_param.php');
    include_once('FetchUtil.php');

    
/*
    $db = ADONewConnection($dbdriver);
    $db->Connect($server, $user, $password, $database);
    $db->SetFetchMode(ADODB_FETCH_ASSOC);
*/

    $dsn = "$dbdriver://$user:$password@$server/$database?clientflags=65536"; 
    $db_sp = new FetchUtil($dsn);

    $productoId = $_REQUEST['productoId'];
    $bodegaId   = $_REQUEST['bodegaId'];
    $tallosBunche = $_REQUEST['tallosBunche'];
    $fechaCorte = $_REQUEST['fechaCorte'];
    $variedadId = $_REQUEST['variedadId'];
    
    
    //$db->debug = true;
	
    $activo = 1;
    
    /*Longitudes*/
    $sql = "CALL GetDisponibilidadVariedad ($productoId,$bodegaId,$tallosBunche,'$fechaCorte', $variedadId)";


	//echo $sql;

    /*llamada al store procedure*/
    $rows_sp = $db_sp->fetchAll($sql);
    
/*
    $i = 0;
    $j = 0;*/

    //Actualizamos la disponibilidad por variedad 

    
    
/*
    echo "<table id=\"tblDisp\" border=\"0\">";
    echo "<thead>";
    echo "<th >ID</th>";
    echo "<th >VARIEDAD</th>";
    echo "<th >DISP</th>";
    echo "<thead>";
    echo "<tbody>";
    
    foreach($rows_sp as $rdata_) {
            
            echo "<tr id=\"".$rdata_['variedad_id']."\">";
            echo "<td>".$rdata_['variedad_id']."</td>";
            echo "<td>".$rdata_['nombre']."</td>";
            echo "<td>".$rdata_['total']."</td>";
			echo "</tr>";
    }
    
    echo "</tbody>";    
    echo "</table>";*/


	echo json_encode($rows_sp);

?>	